From 217ff7fb93a09f97927394249b3359a61a715cc0 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 26 Sep 2014 21:24:31 -0700 Subject: [PATCH] Deprecate `cargo update foo` To maintain consistency with `cargo {build,test,bench,clean}` the `update` subcommand now takes a specific package via the `-p` argument instead of as a positional argument. --- src/bin/update.rs | 37 ++++++++++++++++++---------- tests/test_cargo_compile_git_deps.rs | 3 ++- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/bin/update.rs b/src/bin/update.rs index d7fd67b5f..7424a471b 100644 --- a/src/bin/update.rs +++ b/src/bin/update.rs @@ -10,21 +10,23 @@ docopt!(Options, " Update dependencies as recorded in the local lock file. Usage: - cargo update [options] [] + cargo update [options] + cargo update [options] Options: - -h, --help Print this message - --aggressive Force updating all dependencies of as well - --precise PRECISE Update a single dependency to exactly PRECISE - --manifest-path PATH Path to the manifest to compile - -v, --verbose Use verbose output + -h, --help Print this message + -p SPEC, --package SPEC Package to run benchmarks for + --aggressive Force updating all dependencies of as well + --precise PRECISE Update a single dependency to exactly PRECISE + --manifest-path PATH Path to the manifest to compile + -v, --verbose Use verbose output This command requires that a `Cargo.lock` already exists as generated by `cargo build` or related commands. -If is given, then a conservative update of the lockfile will be -performed. This means that only the dependency specified by will be -updated. Its transitive dependencies will be updated only if cannot be +If SPEC is given, then a conservative update of the lockfile will be +performed. This means that only the dependency specified by SPEC will be +updated. Its transitive dependencies will be updated only if SPEC cannot be updated without updating dependencies. All other dependencies will remain locked at their currently recorded versions. @@ -34,22 +36,31 @@ being updated should be updated to. For example, if the package comes from a git repository, then PRECISE would be the exact revision that the repository should be updated to. -If is not given, then all dependencies will be re-resolved and +If SPEC is not given, then all dependencies will be re-resolved and updated. -For more information about package ids, see `cargo help pkgid`. +For more information about package id specifications, see `cargo help pkgid`. ", flag_manifest_path: Option, arg_spec: Option, - flag_precise: Option) + flag_precise: Option, flag_package: Option) pub fn execute(options: Options, shell: &mut MultiShell) -> CliResult> { debug!("executing; cmd=cargo-update; args={}", os::args()); shell.set_verbose(options.flag_verbose); let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path)); + let spec = if options.arg_spec.is_some() { + let _ = shell.warn("`cargo update foo` has been deprecated in favor \ + of `cargo update -p foo`. This functionality \ + will be removed in the future"); + options.arg_spec.as_ref() + } else { + options.flag_package.as_ref() + }; + let mut update_opts = ops::UpdateOptions { aggressive: options.flag_aggressive, precise: options.flag_precise.as_ref().map(|s| s.as_slice()), - to_update: options.arg_spec.as_ref().map(|s| s.as_slice()), + to_update: spec.map(|s| s.as_slice()), shell: shell, }; diff --git a/tests/test_cargo_compile_git_deps.rs b/tests/test_cargo_compile_git_deps.rs index 8bab2b417..1ab1f0e85 100644 --- a/tests/test_cargo_compile_git_deps.rs +++ b/tests/test_cargo_compile_git_deps.rs @@ -830,7 +830,8 @@ test!(two_deps_only_update_one { add(&repo); commit(&repo); - assert_that(project.process(cargo_dir().join("cargo")).arg("update").arg("dep1"), + assert_that(project.process(cargo_dir().join("cargo")).arg("update") + .arg("-p").arg("dep1"), execs() .with_stdout(format!("{} git repository `{}`\n", UPDATING, git1.url())) -- 2.30.2